<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<tpl> $NCharset </tpl>" />
<tpl>include file ='../head.config.html'</tpl>
<link href="<tpl> $template_dir </tpl>/member/css/layout.css" rel="stylesheet" type="text/css" />
</head><body><tpl>include file ='../header.html'</tpl> 
<div id="container761">
<div class="own_member_main">
<tpl>include file ='own_menu.html'</tpl>
  <div class="member_right">
  <div class="new_main_left">
		<div class="new_main_left1">
		<h1 class="new_text"><tpl> $langBatchProductManage </tpl></h1>
		<i></i>
		</div><b></b>
		</div>
		 <div id="own_main_rightop">
		 	<tpl> $langBatchRemark </tpl>
		 </div>
	<div id="own_main_rightop_line" style="margin-top:-3px;">
	  <b class="b4"></b>
	  <b class="b3"></b>
	  <b class="b2"></b>
	  <b class="b1"></b>
	  </div>
	  <UL class="item_list_title">
	  	<LI class="selected"><a href="javascript:;"><tpl> $langBatchProduct </tpl></a> </LI>
		<LI><a href="own_product_batch.php?action=export"><tpl> $langBatchProductExport </tpl></a> </LI>
      </UL>
    <form action="own_product_batch.php?action=upload" method="post" enctype="multipart/form-data" name="form_batch" id="form_batch">
      <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#DEEBEF"  class="table_white">
        <tr>
          <th width="20%" height="35" align="center" bgcolor="#F5F9FA"><tpl> $langBatchClass </tpl>:　</th>
          <td width="80%" height="35" bgcolor="#FCFEFE">　
		  <input name="searchcate" type="hidden" id="searchcate" /><!-- 商品类别 -->
		  	<select name="c1" id="c1" style="WIDTH: 110px;border:1px solid #ccc;">
				<option value=""></option>
				<tpl>foreach item = parent from = $ProductCateArray</tpl>
					<option value="<tpl>$parent[0]</tpl>||<tpl>$parent[5]</tpl>"><tpl>$parent[2]</tpl></option>
				<tpl>/foreach</tpl>
			</select>
			<select name="c2" id="c2" class="search_high" style="WIDTH: 110px;border:1px solid #ccc;">
			</select>
			<select name="c3" id="c3" class="search_high" style="WIDTH: 110px;border:1px solid #ccc;">
			</select>
			<select name="c4" id="c4" class="search_high" style="WIDTH: 110px;border:1px solid #ccc;">
			</select>
			<label style="display:none" for="searchcate" class="error" metaDone="true" generated="true"></label>  
		  </td>
        </tr>
		<tr>
          <th width="20%" height="35" align="center" bgcolor="#F5F9FA"><tpl> $langBatchUploadFile </tpl>:　</th>
          <td width="80%" height="35" bgcolor="#FCFEFE">
		  	　<input type="file" name="file" id="file" />
			<label style="display:none" for="file" class="error" metaDone="true" generated="true"></label>  
		  </td>
        </tr>
		<tr>
          <th width="20%" height="35" align="center" bgcolor="#F5F9FA"><tpl> $langBatchUploadCSV </tpl>:　</th>
          <td width="80%" height="35" bgcolor="#FCFEFE">
		  	　<input type="radio" name="batch_type" id="batch_type" value="taobao" checked="checked" /><tpl> $langBatchTaobao </tpl>
		  </td>
        </tr>
		<tpl> if $shop_product_cate_array[0].class_id neq '' </tpl>
		<tr>
          <th width="20%" height="35" align="center" bgcolor="#F5F9FA"><tpl> $langBatchShopProductClass </tpl>:　</th>
          <td width="80%" height="35" bgcolor="#FCFEFE">
		  	　<select name="shop_product_category" id="shop_product_category">
				<tpl> section name=loop loop=$shop_product_cate_array </tpl>
				<option value="<tpl> $shop_product_cate_array[loop].class_id </tpl>"><tpl> $shop_product_cate_array[loop].class_name </tpl></option>
					<tpl> foreach from=$shop_product_cate_array[loop].child item=one </tpl>
						<option value="<tpl> $one.class_id </tpl>">&nbsp;&nbsp;<tpl> $one.class_name </tpl></option>
					<tpl> /foreach </tpl>
				<tpl> /section </tpl>
			</select>
		  </td>
        </tr>
		<tpl> /if </tpl>
		<tr>
          <th width="20%" height="35" align="center" bgcolor="#F5F9FA"><tpl> $langBatchCity </tpl>:　</th>
          <td width="80%" height="35" bgcolor="#FCFEFE">
		  <input type="hidden" name="area_id" id="area_id" />
		  	　<select id="area_c1" class="searchformselect" name="area_c1" style="width: 120px">
				<option valus="" selected></option>
				<tpl> foreach item = parent from = $area_array </tpl>
				<option value="<tpl>$parent.area_id</tpl>||<tpl>$parent.is_parent</tpl>"><tpl> $parent.area_name </tpl></option>
				<tpl> /foreach </tpl>
			</select>
			<select class="searchformselect" id="area_c2" style="width: 120px" name="area_c2">
			</select>
			<select class="searchformselect" id="area_c3" style="width: 120px" name="area_c3">
			</select>
			<select class="searchformselect" id="area_c4" style="width: 120px" name="area_c4">
			</select>
          	<label style="display:none" for="area_id" class="error" metaDone="true" generated="true"></label>
		  </td>
        </tr>
		<tr>
          <th width="20%" height="35" align="center" bgcolor="#F5F9FA"><tpl> $langBatchPayment </tpl>:　</th>
          <td width="80%" height="35" bgcolor="#FCFEFE">
		  	　<tpl> foreach from=$payment_array item=one key=key  </tpl>
				<input onclick="if(this.checked == true){select_cur('<tpl> $one.currency_line </tpl>');}else{select_no_cur('<tpl> $one.currency_line </tpl>','<tpl> $key </tpl>');}" 
					type="checkbox" 
					<tpl> if $one.check eq '1' </tpl>checked="checked"<tpl> /if </tpl> 
					value="<tpl> $key </tpl>" 
					name="txtPayment[<tpl> $key </tpl>]" 
					id="txtPayment_<tpl> $key </tpl>" 
				/><tpl> $one.name </tpl>
				<input type="hidden" name="payment_cur_<tpl> $key </tpl>" id="payment_cur_<tpl> $key </tpl>" value="<tpl> $one.currency_line </tpl>" /><!--  该支付方式支持的货币种类  -->
		<tpl> /foreach </tpl>
		  </td>
        </tr>
		<tr>
          <th width="20%" height="35" align="center" bgcolor="#F5F9FA"><tpl> $langBatchExchange </tpl>:　</th>
          <td width="80%" height="35" bgcolor="#FCFEFE">
		  <tpl> foreach from=$exchange_array item=one key=key  </tpl>
				<input type="hidden" name="exchange_rate_<tpl> $one.exchange_name </tpl>" id="exchange_rate_<tpl> $one.exchange_name </tpl>" value="<tpl> $one.exchange_rate </tpl>" /><!-- 汇率 -->
				<div id="div_cur_<tpl> $one.exchange_name </tpl>" style="display:<tpl> $one.display </tpl>"><input type="checkbox" checked="checked" name="currency[<tpl> $one.exchange_name </tpl>]" id="currency_<tpl> $one.exchange_name </tpl>" value="<tpl> $one.exchange_name </tpl>" /><tpl> $one.exchange_remark </tpl>(<tpl> $one.exchange_name </tpl>)
				</div>
			<tpl> /foreach </tpl>
		  </td>
        </tr>
        <tr>
          <th height="35" colspan="2" align="center" valign="middle" bgcolor="#FFFFFF">
		  <input id="Submit" class="new_anniu" type="submit" name="Submit" value="<tpl> $langCsave </tpl>" /></th>
        </tr>
      </table>
    </form>
  </div>
  </div>
<script>
//选中支付方式的时候，显示对应的货币种类
function select_cur(str){
	if(str.indexOf('|') >= 0){
		line = str.split('|');
		for(i=0;i<line.length;i++){
			$("#div_cur_"+line[i]).css("display",'');
		}
	}else{
		$("#div_cur_"+str).css("display",'');
	}
}
//取消支付方式的时候，隐藏对应的货币种类
function select_no_cur(str,payment_name){
	//取该支付方式支持的货币种类str
	cur_array = str.split('|');
	for(i=0;i<cur_array.length;i++){
		//取其他支付方式，判断是否有该种货币的信息，并且判断是否勾选，如果没有勾选，则隐藏并且取消够先该货币种类
		cur_sign = false;
		$('#form_batch input[@type=hidden]').each(function(){//每种支付方式对应的货币字符串
			//判断其他的支付方式是否也存在该货币种类
			if('payment_cur_'+payment_name != this.name && this.name.indexOf('payment_cur_') >= 0){
				other_cur_array = this.value.split('|');
				payment_pro_name = this.name.replace('payment_cur_','txtPayment_');
				for(j=0;j<other_cur_array.length;j++){
					if(cur_array[i] == other_cur_array[j] && $('#'+payment_pro_name).attr('checked') == true){
						//存在
						cur_sign = true;
					}
				}
				payment_pro_name = '';
			}
		})
		//说明其他支付方式没有该货币种类，则可以隐藏并且取消该货币的层和复选
		if(cur_sign == false){
			$("#div_cur_"+cur_array[i]).css("display",'none');
			$("#currency_"+cur_array[i]).attr("checked",false);
		}
	}
}
//调用商品类别
function tonext(whos) {
	$(whos).change(function(){
		var valarray=$(this).val().split('||');	
		$('#searchcate').val(valarray[0]);	
		if (valarray[1]=='1') {
			$(this).next().attr('disabled','true').html('<option value="" selected="selected"><tpl> $langPDataToLoad </tpl></option>');
			$.get('../member/own_productcate.php',{action:'list',id:valarray[0],random_number:Math.random()},function(data){
				DataArray = data.split("|||");var a='';for (var i = 0; i<DataArray.length-1; i++) {att=DataArray[i].split("||");id=att[0];cla=att[2];a+='<option value="'+id+'||'+cla+'">'+att[1]+((cla=='1')?' ->':'')+'</option>';};
				$(whos).next().removeAttr('disabled').html(a).nextAll().html('');
				tonext($(whos).next());
			})
		}else {
			$(whos).nextAll().html('').attr('disabled','true');
		};
	})
};
//地区调用
function area_tonext(whos) {
	$(whos).change(
		function(){
			var valarray=$(this).val().split('||');	
			$('#area_id').val(valarray[0]);
			if (valarray[1]=='1') {
				$(this).next().attr('disabled','true').html('<option value="" selected="selected"><tpl> $langCDataToLoading </tpl></option>');
				$.get(
					'../home/tohtml.php',
					{action:'get_area',id:valarray[0],random_number:Math.random()},
					function(data){
						DataArray = data.split("|||");
						var a='';
						for (var i = 0; i<DataArray.length-1; i++) {
							att=DataArray[i].split("||");
							id=att[0];
							cla=att[2];
							a+='<option value="'+id+'||'+cla+'">'+att[1]+((cla=='1')?' ->':'')+'</option>';
						}
						
					$(whos).next().removeAttr('disabled').html('<option value="" selected="selected"></option>'+a).nextAll().html('');
					area_tonext($(whos).next());
					}
				)
			} else {
				$(whos).nextAll().html('').attr('disabled','true');
			};
		}
	)
};


$().ready(function() {
	//商品类别
	tonext('#c1');
	//地区调用
	area_tonext("#area_c1");
	//表单验证
	$("#form_batch").validate({
		errorClass: "wrong",
		rules: {
			searchcate: {required: true},
			file: {required: true},
			area_id: {required: true}
		},
		messages: {
			searchcate: {required: "<tpl> $errBatchProductClassIsEmpty </tpl>"},
			file: {required: "<tpl> $errBatchFileIsEmpty </tpl>"},
			area_id: {required: "<tpl> $errBatchAreaIsEmpty </tpl>"}
		},
		submitHandler: function() {
			var check_sign = false;//货币选择状态标识
			var payment_check = false;//支付方式选择状态标识
			var payment_alert_sign = false;//支付方式是否抛出错误信息标识
			//验证支付方式的复选验证，是否全选，选中的支付方式是否选择了支付货币种类
			$("#form_batch input[@type=hidden]").each(function(){
				if(this.name.indexOf('payment_cur_') == 0){
					//判断支付方式是否被选择
					str = this.name.split('payment_cur_');//取支付方式名称 str[1]
					if($('#txtPayment_'+str[1]).attr('checked') == true){
						//取该支付方式的货币种类字符串
						str2 = $('#payment_cur_'+str[1]).val().split('|');
						payment_check = true;//标识有选择的支付方式
						//判断该选中的支付方式起码有一个支持的货币种类被选择
						for(i=0;i<str2.length;i++){
							if($('#currency_'+str2[i]).attr('checked') == true){
								check_sign = true;
								break;
							}
						}
						if(check_sign == false){//没有选择货币
							payment_alert_sign = true;
						}
					}
				}
				check_sign = false;
			});
			if(payment_alert_sign == false && payment_check == true){//判断是否有错误抛出并且选择了起码一种支付方式:没有
				$('#form_batch').ajaxSubmit();
			}else{
				alert('<tpl> $errBatchPaymentIsEmpty </tpl>');
				return false;
			}
		}
	});
});
</script>
  <tpl> include file ='../../../html/footer.html' </tpl> </div>
</body>
</html>
